<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <div id="app">
    <my-cpn></my-cpn>
    <cpn></cpn>
  </div>
  <div id="app1">
    <my-cpn></my-cpn>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    //   const myComponent = Vue.extend({
    //     template: `<div>
    //   <h3>我是全局组件的标题</h3>
    //   <p>我是全局组件的内容</p>
    // </div>`,
    //   }); // 创建组件构造器

    //   // 注册为全局组件
    //   Vue.component("myCpn", myComponent);

    // 注册1为全局组件
    Vue.component("myCpn", {
      template: `<div>
        <h3>我是全局组件的标题</h3>
        <p>我是全局组件的内容</p>
      </div>`,
    });

    const app = new Vue({
      el: "#app",
      data: {
        message: "hello",
      },
      components: {
        cpn: {
          template: `<div>
        <h3>我是局部组件的标题</h3>
        <p>我是局部组件的内容</p>
      </div>`,
        },
      },
    });

    const app1 = new Vue({
      el: "#app1",
    });
  </script>
</body>

</html>